/**
 * 
 */
package com.maywide.jdp.system.rule;

import java.lang.reflect.Method;

import javax.servlet.http.HttpSession;

import com.maywide.jdp.core.vo.Context;

/**
 * @author Administrator
 *
 */
public class OrganizationTreeAdvice extends RuleAdviceImpl {

	/* (non-Javadoc)
	 * @see org.springframework.aop.MethodBeforeAdvice#before(java.lang.reflect.Method, java.lang.Object[], java.lang.Object)
	 */
	public void before(Method method, Object[] args, Object target)
			throws Throwable {
		HttpSession session = (HttpSession)args[4];
		Context context = (Context)session.getAttribute("context");
		String currentOrganization = context.getCurrentOrganization();
		String parentID = (String)args[0];
		if ("org_root".equals(parentID) || "oper_org_root".equals(parentID)
				|| "role_org_root".equals(parentID) || "param_org_root".equals(parentID))
			parentID = null;
		if(currentOrganization != null && parentID == null)
			args[1] = currentOrganization.split(",")[0];
	}

	public void afterReturning(Object arg0, Method arg1, Object[] arg2,
			Object arg3) throws Throwable {
		// do nothing
		
	}
}
